package com.cheung.leetcode.normal;

import java.util.ArrayList;
import java.util.List;

public class LC77 {


    public static List<List<Integer>> combine(int n, int k) {
        List<List<Integer>> result = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        backtracking(result, path, n, k, 1);
        return result;
    }


    private static void backtracking(List<List<Integer>> result, List<Integer> path,
                                     int n, int k, int begin) {
        if (path.size() == k) {
            result.add(new ArrayList<>(path));
            return;
        }

        for (int i = begin; i <= n; i++) {
            path.add(i);
            backtracking(result, path, n, k, i + 1);
            path.remove(path.size() - 1);
        }


    }

    public static void main(String[] args) {
        int n = 1, k = 1;
        System.out.println(combine(n, k));
    }
}
